
class Employee:
    def __init__(self, eid, did, name, money):
        self.eid = eid  # 员工编号
        self.did = did  # 部门编号
        self.name = name
        self.money = money

    def __repr__(self):
        return f'Employee({self.eid}, {self.did}, {self.name}, {self.money})'



list_employees = [
    Employee(1001, 9002, "师父", 60000),
    Employee(1002, 9001, "孙悟空", 50000),
    Employee(1003, 9002, "猪八戒", 20000),
    Employee(1004, 9001, "沙僧", 30000),
    Employee(1005, 9001, "小白龙", 15000),
]

# 求所有员工中工资最高的员工信息
# 假设第一个员工工资最高
# maxv = list_employees[0]
# for i in range(1,len(list_employees)):
#     if maxv.money < list_employees[i].money:
#         maxv = list_employees[i]
#
# print(maxv)

# def condition01(item):
#     return item.money

def get_max(condition):
    maxv = list_employees[0]
    for employee in list_employees:
        if  condition(maxv) < condition(employee):
            maxv = employee
    return maxv

# print(get_max(condition01))
print(get_max(lambda item:item.money))


# 求所有员工的工资总和
# def get_sum():
#     total = 0
#     for employee in list_employees:
#         total += employee.money
#     return total
#
# print(get_sum())

# def func01(item):
#     return item.money

def sum_money(func):
    total = 0
    for employee in list_employees:
        total += func(employee)
    return total

# print(sum_money(func01))
print(sum_money(lambda x:x.money))
print(sum_money(lambda x:x.eid))
print(sum_money(lambda x:x.did))